package manage.model;

import m.common.model.FieldMeta;
import m.common.model.LinkTableMeta;
import m.common.model.Model;
import m.common.model.TableMeta;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;
import m.system.cache.FlushCache2;

@TableMeta(name="os_admin_column",description="管理员列设置表")
public class AdminColumn extends Model implements FlushCache2 {
    @LinkTableMeta(name="admin_oid",table=AdminLogin.class,description="所属管理员")
    private AdminLogin admin;
    @FieldMeta(name="url",type= FieldType.STRING,length=500,description="请求的url")
    private String url;
    @FieldMeta(name="columns_param_key",type= FieldType.STRING,length=50,description="真实请求的MD5")
    private String columnsParamKey;
    @FieldMeta(name="view_params",type= FieldType.STRING,length=2000,description="显示参数")
    private String viewParams;

    public String getColumnsParamKey() {
        return columnsParamKey;
    }

    public void setColumnsParamKey(String columnsParamKey) {
        this.columnsParamKey = columnsParamKey;
    }

    public AdminLogin getAdmin() {
        return admin;
    }

    public void setAdmin(AdminLogin admin) {
        this.admin = admin;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getViewParams() {
        return viewParams;
    }

    public void setViewParams(String viewParams) {
        this.viewParams = viewParams;
    }

    @Override
    public AdminColumn getCacheModel(String adminOid, String columnsParamKey) throws Exception {
        return ModelQueryList.getModel(AdminColumn.class,new String[]{"*"},
            QueryCondition.and(
                QueryCondition.eq("admin.oid",adminOid),
                QueryCondition.eq("columnsParamKey",columnsParamKey)
            ));
    }
}
